<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/27 0027
 * Time: 14:32
 */

namespace app\index\model;
use think\Db;
use think\Model;
use think\Request;

class prizes extends Model
{
    /**获取兑换奖品数据和分页功能
     * @param Request $request
     * @return array
     */
    public function getPrizes(Request $request)
    {
        $page = $request->param('page',1);
        $limit = $request->param('limit',10);
        $sule = Db::connect();
        $shu = $sule->name('prizes')->count();
        $data = $sule->name('prizes')->limit(($page-1)*$limit,$limit)->select();
        return [$shu,$data];
    }

    /**更新prizes表
     * @param $data
     * @return bool
     */
    public static function updatePrizes($data){
        if(Db::name('prizes')->where('id',$data['id'])->update($data)){
            return true;
        }else{
            return false;
        }
    }

}